package com.starlink.controller.wechat;

import com.starlink.common.PageInfoTwo;
import com.starlink.common.WebResponse;
import com.starlink.common.annotation.WebAccess;
import com.starlink.model.request.MallBooksRequest;
import com.starlink.model.vo.MallBooksVO;
import com.starlink.service.MallBooksService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author: zyh
 * @date: 2024-04-01
 */
@RestController
@RequestMapping("/wechat/mallbook")
@Api(value = "【小程序端】商城书籍基本信息模块", tags = {"【小程序端】商城书籍基本信息模块"})
public class WechatMallBooksController {
    @Autowired
    private MallBooksService mallBooksService;

    @WebAccess(login = true)
    @ApiOperation(value = "根据主键查询", httpMethod = "POST")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "success")})
    @PostMapping("/get/{id}")
    public WebResponse<MallBooksVO> getByKey(@PathVariable("id") long id) {
        return WebResponse.build(mallBooksService.getByKey(id));
    }

    @WebAccess(login = true)
    @ApiOperation("分页查询")
    @PostMapping("/pageQuery")
    public WebResponse<PageInfoTwo<MallBooksVO>> pageQuery(@RequestBody MallBooksRequest request) {
        return WebResponse.build(mallBooksService.pageQuery(request));
    }

    @WebAccess(login = true)
    @ApiOperation("列表查询")
    @PostMapping("/listQuery")
    public WebResponse<List<MallBooksVO>> listQuery(@RequestBody MallBooksRequest request) {
        return WebResponse.build(mallBooksService.listQuery(request));
    }

}
